package com.hducms.cms.action.front;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hducms.cms.entity.main.CmsUser;
import com.hducms.cms.service.CmsUserService;
import com.hducms.cms.web.CmsUtils;
import com.hducms.common.web.ResponseUtils;

@Controller
public class ClientInforUpdate {

	@RequestMapping(value="/updateClientId.m")
	public void updateClientId(HttpServletRequest request,HttpServletResponse response,
			String clientId) {
		CmsUser user = CmsUtils.getUser(request);
		if (clientId.equals("")) {
			ResponseUtils.renderJson(response, "0");
			return;
		}
		try {
			userService.updateGetuiClientId(clientId,user.getUserId());
		} catch (Exception e) {
			ResponseUtils.renderJson(response, "0");
			return;
		}
		ResponseUtils.renderJson(response, "1");
		return;
	}
	
	@RequestMapping(value="/updatePatternLock.m")
	public void updatePatternLock(HttpServletRequest request,HttpServletResponse response,
			String passw) {
		CmsUser user = CmsUtils.getUser(request);
		if (passw.equals("")) {
			ResponseUtils.renderJson(response, "0");
			return;
		}
		try {
			userService.updatePatternLock(user.getUserId(),passw);
		} catch (Exception e) {
			ResponseUtils.renderJson(response, "0");
			return;
		}
		ResponseUtils.renderJson(response, "1");
		return;
	}
	
	@Autowired
	private CmsUserService userService;
}
